/*
 * CellSubSystem.h
 *
 *  Created on: Apr 25, 2017
 *      Author: zhangjf
 */

#ifndef SRC_CELLSUBSYSTEM_CELLSUBSYSTEM_H_
#define SRC_CELLSUBSYSTEM_CELLSUBSYSTEM_H_

#include <Poco/JSON/Object.h>
#include <Poco/Logger.h>
#include <Poco/Util/Subsystem.h>
#include <Poco/File.h>
#include <tuple>
#include <vector>

#include "NCSSubsystem.h"

using namespace std;
using namespace Poco;
using namespace Poco::Util;
using namespace Poco::JSON;
using namespace util;

namespace cell
{

class CellSubsystem: public NCSSubsystem
{
public:
	CellSubsystem();
	virtual ~CellSubsystem();

	const char* name() const { return _name.c_str(); }
	const static CellSubsystem& instance() { if (_pInstance == nullptr) _pInstance = new CellSubsystem(); return *_pInstance; }

	//Logger& logger() const { return _logger; }

	bool registerCellType(std::string& cellType, std::string& fileName);
	bool addApp(std::string& cellType, std::string& appName, UInt32& appID);

protected:
	void initialize(Application& self);
	void uninitialize();

private:
	static const std::string _name;
	static CellSubsystem* _pInstance;
	static std::vector<std::tuple<std::string, std::string>> _systemCellList;	//tuple<CellType, Path>

	static const std::string _spc_original_path;
	static const std::string _spc_file_path;

	//Poco::Logger& _logger;

	bool registerCellType_1(std::string& cellType, string& zipFile, Object::Ptr& joCellInfo);

};

} /* namespace cell */

#endif /* SRC_CELLSUBSYSTEM_CELLSUBSYSTEM_H_ */
